//
//  MainTabBarController.m
//  quickLook
//
//  Created by J on 15/8/30.
//  Copyright (c) 2015年 JZJ. All rights reserved.
//

#import "MainTabBarController.h"

#import "QuickLookViewController.h"
#import "FindViewController.h"
#import "IndividualViewController.h"
#import "Header.h"
#import "ABCIntroView.h"//引导页

@interface MainTabBarController ()<ABCIntroViewDelegate>
@property(nonatomic,strong)  ABCIntroView* introView;

@end

@implementation MainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self createUI];

    [self introVC];//调用欢迎页
//    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
//
//    [defaults setObject:nil forKey:@"intro_screen_viewed"];
//    [defaults synchronize];

    
}



//欢迎页

- (void)introVC{
    
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if (![defaults objectForKey:@"intro_screen_viewed"]) {
        self.introView = [[ABCIntroView alloc] initWithFrame:self.view.frame];
        self.introView.delegate = self;
        self.introView.backgroundColor = [UIColor greenColor];
        [self.view addSubview:self.introView];
        
        [defaults setObject:@"d" forKey:@"intro_screen_viewed"];
        
        
    }
    
    
}


-(void)onDoneButtonPressed{
    //    Uncomment so that the IntroView does not show after the user clicks "DONE"
    //    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]
    //    [defaults setObject:@"YES"forKey:@"intro_screen_viewed"];
    //    [defaults synchronize];
    [UIView animateWithDuration:1.0 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        self.introView.alpha = 0;
    } completion:^(BOOL finished) {
        [self.introView removeFromSuperview];
    }];
}


- (void)createUI
{
    
    //设置文字颜色
    //appearance是用于修改系统默认参数，在修改后，以后创建的全都遵循这个设置
    //未选中颜色
    [[UITabBarItem appearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:JZJLIGHTGRAY} forState:UIControlStateNormal];
    
    //选中的颜色
    [[UITabBarItem appearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:JZJGRAY} forState:UIControlStateSelected];
    

    
    

    
    
#pragma mark --quickLookVC是球
    QuickLookViewController *quickLookVC = [[QuickLookViewController alloc]init];    //    设置标签，标记一下
    UINavigationController *quickLookNav = [[UINavigationController alloc] initWithRootViewController:quickLookVC];
    
    quickLookVC.title=@"推荐";
    
    
    quickLookNav.navigationBar.barTintColor=JZJYELLOW;
    
    
    quickLookVC.view.backgroundColor=[UIColor whiteColor];
  
    
    
#pragma mark --findViewVC是杯子
    FindViewController *findViewVC = [[FindViewController alloc]init];
    UINavigationController *findNav = [[UINavigationController alloc] initWithRootViewController:findViewVC];
    findViewVC.title=@"发现";
    findViewVC.view.backgroundColor=[UIColor whiteColor];

    findNav.navigationBar.barTintColor=JZJYELLOW;

#pragma mark --IndividualVC是杯子
    IndividualViewController *IndividualVC = [[IndividualViewController alloc]init];
    UINavigationController *IndividualNav = [[UINavigationController alloc] initWithRootViewController:IndividualVC];
    
    IndividualNav.navigationBar.barTintColor=JZJYELLOW;

    
    IndividualVC.title=@"个人";

//    IndividualVC.view.backgroundColor=[UIColor whiteColor];
    
    
    
#pragma mark --创建篮子
    self.viewControllers = @[quickLookNav,findNav,IndividualNav];
    

    
    
    
    
    //3个数组 选中  未选中  title
    
    NSArray* unSelectImageNameArray=@[@"unselected11",@"unselected22",@"unselected32"];
    
    
    NSArray* selectImageNameArray=@[@"selected11",@"selected22",@"selected32"];
    NSArray* titleArray=@[@"推荐",@"专题",@"个人"];
    
    
    UITabBar *tabBar=self.tabBar;
    
    
    //循环读取tabbarItem
    for (int i=0; i<tabBar.items.count; i++) {
        UIImage*image=[[UIImage imageNamed:unSelectImageNameArray[i]] TransformtoSize:CGSizeMake(25, 25)];
        //对图像进行处理
        UIImage * unselectedImage=[image TransformtoSize:CGSizeMake(25, 25)];
        
        
        UIImage * selectedImage = [[UIImage imageNamed:selectImageNameArray[i]]TransformtoSize:CGSizeMake(25, 25)];
        
        
        
        UITabBarItem*itme=tabBar.items[i];
        itme= [itme initWithTitle:titleArray[i] image:[unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ]];
        
        
    }
    
    

    
}


@end
